//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package ccy.ccysolarcount.listener;

import ccy.ccylibrary.plugin.annotation.Event;
import ccy.ccysolarcount.config.CcyConfig;
import ccy.ccysolarcount.playerdata.PlayerData;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;

@Event
public class PlayerJoinQuitListener implements Listener {
    public PlayerJoinQuitListener() {
    }

    @EventHandler
    public void ouJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        PlayerData playerData = new PlayerData(player);
        CcyConfig.config.temp_tyn1.put(player.getUniqueId(), playerData.getTyn1());
        CcyConfig.config.temp_tyn2.put(player.getUniqueId(), playerData.getTyn2());
    }

    @EventHandler
    public void onQuit(PlayerQuitEvent event) {
        Player player = event.getPlayer();
        if (CcyConfig.config.temp_tyn1.containsKey(player.getUniqueId())) {
            PlayerData playerData = new PlayerData(player);
            playerData.setTyn1(CcyConfig.config.temp_tyn1.get(player.getUniqueId()));
            CcyConfig.config.temp_tyn1.remove(player.getUniqueId());
        }

        if (CcyConfig.config.temp_tyn2.containsKey(player.getUniqueId())) {
            PlayerData playerData = new PlayerData(player);
            playerData.setTyn1(CcyConfig.config.temp_tyn2.get(player.getUniqueId()));
            CcyConfig.config.temp_tyn2.remove(player.getUniqueId());
        }

    }
}
